package com.kawins.mina.core;

import org.apache.log4j.Logger;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by think on 2016/1/5.
 */
public class UriMapping {

	private Logger log = Logger.getLogger(getClass());

	private final Map<String, MethodInvoker> uri = new HashMap<String, MethodInvoker>();

	private UriMapping() {
	}

	public Map<String, MethodInvoker> getUri() {
		return uri;
	}

	private static class UriMappingInstance {
		public static UriMapping instance = new UriMapping();
	}

	public MethodInvoker getMethod(String key) {
		return uri.get(key);
	}

	public static UriMapping getInstance() {
		return UriMappingInstance.instance;
	}

	public void put(String key, MethodInvoker m) {
		if (!uri.containsKey(key)) {
			uri.put(key, m);
		} else {
			log.error("the same uri is not allowed");
		}
	}

}
